<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <link rel="stylesheet" href="css/login.css">
</head>
<body>
    <!-- 用这个元素作为页面的版心,把对话框放到这个元素里,水平居中 -->
    <div class="login-container">
        <!-- 登录对话框 -->
        <div class="dialog">
            <div class="row">
                <span>用户名:</span>
                <input type="text" id="username">
            </div>
            <div class="row">
                <span>输入密码:</span>
                <input type="text" id="password">
            </div>
            <div class="row">
                <span>确认密码:</span>
                <input type="text" id="password">
            </div>
            <div class="pwo">
                <button id="login-btn">登录</button>
            </div>
        </div>
    </div>
    <script>
        let container = document.querySelector('.container');
        let button = document.querySelector('button');
        button.onclick = function() {
            //1.获取到输入框的内容
            let inputs = document.querySelectorAll('input');
            let from = inputs[0].value;
            let to = inputs[1].value;
            let message = inputs[2].value;
            if (from == '' || to == '' || message == ''){
                alert('当前输入框的内容为空!');
                return
            }
            console.log(from + "," + to + "," + message);
            let rowDiv = document.createElement('div');
            rowDiv.className = 'row';
            rowDiv.innerHTML = from + "对" + to + "说" + message;
            container.appendChild(rowDiv);
            for (let i = 0; i < inputs.length; i++){
                inputs[i].value = '';
            }
        }
    </script>
</body>
</html>